<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('新增缓存线管理')"/>
    <style>
        [v-cloak] {
            display: none;
        }
    </style>
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-shelfPlan-add">
            <div class="form-group">
                <label class="col-sm-3 control-label">缓存线编码：</label>
                <div class="col-sm-8">
                    <select id="shelfId" name="shelfId" class="form-control">
                        <option v-for="(item, index) in shelfs" :key="index" :value="item.shelfId" v-cloak>{{item.shelfCode}}</option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">缓存线状态：</label>
                <div class="col-sm-8">
                    <select id="state" name="state" class="form-control" @blur="changeShow()">
                        <option value="1">OK</option>
                        <option value="-1">NG</option>
                    </select>
                </div>
            </div>
            <div class="form-group" v-if="show">
                <label class="col-sm-3 control-label">NG原因：</label>
                <div class="col-sm-8">
                    <input id="description" name="description" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">单晶PN型：</label>
                <div class="col-sm-8">
                    <select id="materialPN" name="materialPN" class="form-control">
                        <option value="P">P</option>
                        <option value="N">N</option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">客户等级：</label>
                <div class="col-sm-8">
                    <select id="materialCategory" name="materialCategory" class="form-control">
                        <option value="A">A</option>
                        <option value="A+H">A+H</option>
                        <option value="A-">A-</option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">单晶规格：</label>
                <div class="col-sm-8">
                    <select id="spec" name="spec" class="form-control">
                        <option value="G12">G12</option>
                        <option value="M6">M6</option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">拼棒类型：</label>
                <div class="col-sm-8">
                    <select id="assemblyType" name="assemblyType" class="form-control">
                        <option value="1">整棒</option>
                        <option value="2">二拼</option>
                        <option value="3">三拼</option>
                    </select>
                </div>
            </div>
        </form>
    </div>
<div th:include="include::footer"></div>
<script type="text/javascript">
    var prefix = ctx + "ShelfPlan"

    function submitHandler(){
        if($.validate.form()){
            $.operate.save(prefix + "/insert", $('#form-shelfPlan-add').serialize());
        }
    }

    var app = new Vue({
        el: '.wrapper',
        data: {
            shelfs: [],
            show: false
        },
        methods: {
            getShelfs(){
                var that = this;
                $.ajax({
                    cache: true,
                    type: "POST",
                    url: "/system/shelfInfo/list",
                    data: {},
                    async: false,
                    error: function(request){
                        $.modal.alertError("系统错误");
                    },
                    success: function(data){
                        that.shelfs = data.rows;
                    }
                });
            },
            changeShow(){
                var currentSel = document.getElementById('state');
                var index = currentSel.selectedIndex;
                var value = currentSel.options[index].value;
                if(value == -1){
                    this.show = true;
                }else{
                    this.show = false;
                }
            }
        },
        created(){
            this.getShelfs();
        }
    })
</script>
</body>
</html>
